<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<div class="row">
	<div class="col-lg-12 col-sm-12 col-xs-12">
		<div class="widget">
			<div class="widget-header bordered-bottom theme">
				<span class="widget-caption">菜单权限-${(editModel=='add')?string('新增','编辑')}</span>
				<div class="widget-buttons">
					<a href="#" data-toggle="collapse">
						<i class="fa fa-minus"></i>
					</a>
					<a href="#" data-toggle="maximize">
						<i class="fa fa-expand"></i>
					</a>
				</div>
			</div>
			<div class="widget-body">
				<div class="row">
					<form class="editForm" action="${saveUrl}" method="post" responseType="JSON" role="form" id="editForm_${serializeNum}"
						data-bv-submitButtons="#editFormSubmitBtn_${serializeNum}"
						data-bv-message="This value is not valid"
						data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
						data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
						data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
						<input type="hidden" name="formKey" value="${formKey}">
						<input type="hidden" name="formToken" value="${formToken}">
						<input type="hidden" name="id" value="${editEntity.id}">
						<#if (true && editModel=='add')||(true && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group">
								<label for="pId" class="col-sm-2 control-label no-padding-right">父菜单</label>
								<div class="col-sm-10">
									<select name="pId" class="selectpicker_${serializeNum}" data-live-search="true">
									<optgroup label="选择所属分组" data-icon="icon-ok">
										<option value="">无</option>
										<#list pId_datasources as datasources >
											<option value="${datasources.id}">${datasources.name}</option>
										</#list>
									</optgroup>
									</select>
									<script type="text/javascript">
										$("[name='pId']").val("${editEntity.pId}");
									</script>
								</div>
							</div>
						</div>
						</#if>
						<#if (true && editModel=='add')||(true && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group">
								<label for="name" class="col-sm-2 control-label no-padding-right">名称</label>
								<div class="col-sm-10">
									<input required="required" data-bv-message="The field is not valid"maxlength="24" name="name" alt="名称" id="name" placeholder="名称" type="text" title="名称" class="form-control"  value="${editEntity.name}" />
									<span class="text"></span>
								</div>
							</div>
						</div>
						</#if>
						<#if (true && editModel=='add')||(true && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group">
								<label for="icon" class="col-sm-2 control-label no-padding-right">图标</label>
								<div class="col-sm-10">
									<input data-bv-message="The field is not valid"maxlength="100" name="icon" alt="图标" id="icon" placeholder="图标" type="text" title="图标" class="form-control"  value="${editEntity.icon}" />
									<span class="text"></span>
								</div>
							</div>
						</div>
						</#if>
						<#if (true && editModel=='add')||(true && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group">
								<label for="url" class="col-sm-2 control-label no-padding-right">链接</label>
								<div class="col-sm-10">
									<textarea style="width: 100%; height: 100px; resize: none;" required="required" data-bv-message="The field is not valid"maxlength="2000" name="url" alt="链接" id="url" placeholder="链接" type="text" title="链接" class="form-control">${editEntity.url}</textarea>
									<span class="text"></span>
								</div>
							</div>
						</div>
						</#if>
						<#if (true && editModel=='add')||(true && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group">
								<label for="weight" class="col-sm-2 control-label no-padding-right">权重</label>
								<div class="col-sm-10">
									<input required="required"  data-bv-integer-message="The field is number" data-bv-message="The field is not valid" data-bv-integer="true"maxlength="11" name="weight" alt="权重" id="weight" placeholder="权重" type="text" title="权重" class="form-control"  value="${editEntity.weight}" />
									<span class="text"></span>
								</div>
							</div>
						</div>
						</#if>
						<#if (true && editModel=='add')||(true && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group has-feedback">
								<label for="isForbidden" class="col-sm-2 control-label no-padding-right">是否禁用</label>
								<div class="col-sm-10">
									<input type="hidden" name="isForbidden" value=${(editEntity.isForbidden???string(editEntity.isForbidden?string('true','false'),'false'))!'false'}>
									<label>
										<input data-target-input-name="isForbidden" data-bv-message="The field is not valid"maxlength="1" alt="是否禁用" id="isForbidden" placeholder="是否禁用" type="checkbox" title="是否禁用" class="form-control checkbox-slider slider-icon yesno"  ${(editEntity.isForbidden???string(editEntity.isForbidden?string('checked',''),''))!''}>
										<span class="text"></span>
									</label>
								</div>
							</div>
						</div>
						</#if>
						<#if (false && editModel=='add')||(false && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group">
								<label for="createTime" class="col-sm-2 control-label no-padding-right">创建时间</label>
								<div class="col-sm-10">
									<span class="input-icon icon-left">
										<input data-bv-date-format="YYYY-MM-DD hh:mm:ss" data-bv-message="The field is not valid" data-bv-date-message="请正确输入一个时间" data-bv-date="true"maxlength="19" name="createTime" alt="创建时间" id="createTime" placeholder="创建时间" type="text" title="创建时间" class="form-control form-control date-picker" onfocus="WdatePicker({doubleCalendar:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"  value="${editEntity.createTime}"/>
										<i class="fa fa-calendar"></i>
									</span>
								</div>
							</div>
						</div>
						</#if>
						<#if (false && editModel=='add')||(false && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group">
								<label for="createUserId" class="col-sm-2 control-label no-padding-right">创建人Id</label>
								<div class="col-sm-10">
									<input data-bv-message="The field is not valid"maxlength="32" name="createUserId" alt="创建人Id" id="createUserId" placeholder="创建人Id" type="text" title="创建人Id" class="form-control"  value="${editEntity.createUserId}" />
									<span class="text"></span>
								</div>
							</div>
						</div>
						</#if>
						<#if (false && editModel=='add')||(false && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group">
								<label for="version" class="col-sm-2 control-label no-padding-right">版本</label>
								<div class="col-sm-10">
									<input  data-bv-integer-message="The field is number" data-bv-message="The field is not valid" data-bv-integer="true"maxlength="11" name="version" alt="版本" id="version" placeholder="版本" type="text" title="版本" class="form-control"  value="${editEntity.version}" />
									<span class="text"></span>
								</div>
							</div>
						</div>
						</#if>
						<#if (true && editModel=='add')||(false && editModel=='edit')>
						<div class="col-xm-12 col-sm-6 col-lg-4">
							<div class="form-group">
								<label for="handlePermissionIdentifier" class="col-sm-2 control-label no-padding-right">操作权限标识</label>
								<div class="col-sm-8">
									<input required="required"  name="handlePermissionIdentifier" alt="操作权限标识" id="handlePermissionIdentifier" placeholder="操作权限标识" type="text" title="操作权限标识" class="form-control"  value="${editEntity.handlePermissionIdentifier}" />
									<span class="text"></span>
								</div>
								<div class="col-sm-1">
									<a class="btn btn-success" onclick="genHandlePermissionIdentifier()">生成</a>
								</div>
							</div>
							<p class="red">注意：操作权限标识符将参与该菜单权限下所有操作权限的是实际编码,固在所有菜单权限下此标识应保持唯一,且不允许做二次修改</p>
						</div>
						<#else>
							<input type="hidden"  name="handlePermissionIdentifier" value="${editEntity.handlePermissionIdentifier}">
						</#if>
						<div class="col-sm-12">
							<input type="button" class="btn btn-default" data-dismiss="modal" value="返回" onclick="backView()"/>
							<button type="submit" class="btn btn-blue" id="editFormSubmitBtn_${serializeNum}">保存</button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="assets/js/validation/bootstrapValidator_init.js"></script>
<script>
$(".selectpicker_${serializeNum}").select2();
/**
 * 根据菜单名称生成菜单操作权限唯一标识
 */
function genHandlePermissionIdentifier(){
	var menuName=$("#editForm_${serializeNum} [name='name']");
	if(!menuName.val()){
		alert("请先输入菜单名!");
		menuName.focus();
		return ;
	}
	ajaxRequest("sysMenuPermissionsController/genHandlePermissionIdentifier.do?timer="+new Date().getTime(), {menuName:menuName.val()}, function(result) {
		$("#editForm_${serializeNum} [name='handlePermissionIdentifier']").val(result.data);
	},
	function(XMLHttpRequest, textStatus, errorThrown) {
		ajaxError(errorThrown);
	},"GET", "JSON");
}
</script>